﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Demo.Services.Services.Impl.Managers;
using Demo.Services.Contracts.DTO.Infos;
using Ext.Net.MVC;
using Demo.CommonBase.DTO.Infos;
using System.Web.Mvc;
using Ext.Net;
using Manager = Demo.Services.Services.Impl.Managers;

namespace Demo.Web.MVC.Controllers
{
    public class ResourceController : System.Web.Mvc.Controller
    {
        //
        // GET: /Resource/
        public ActionResult ResourceList()
        {
            return this.View();
        }
        public StoreResult Resources(int start, int limit, string sort)
        {
            string direction = "ASC";
            if (!string.IsNullOrEmpty(sort))
            {
                DataSorter ds = JSON.Deserialize<DataSorter[]>(sort)[0];
                direction = ds.Direction.ToString();
                sort = ds.Property.ToString();
            }
            PaginationInfo pagin = new PaginationInfo(start, limit, sort, direction);
            Manager.ResourceManager manager = new Manager.ResourceManager();
            IList<ResourceInfo> resources;
        //    resources = manager.GetResources(pagin);
         //   int total = resources.Count;
            return null;// new StoreResult(resources, 14);
        }
       

        //
        // GET: /Resource/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /Resource/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /Resource/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        
        //
        // GET: /Resource/Edit/5
 
        public ActionResult Edit(Nullable<int> id )
        {
            return View();
        }

        //
        // POST: /Resource/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Resource/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /Resource/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
